import platform = require('../../../../../platform/common/baseCommon');
import appClient = require('../../../../../platform/client/appClient');
import platformControls = require('../../../../../platform/client/controls');
import echartControls = require('../../../../../platform/client/echartControls')
import report = require('../../../../../platform/client/report');
import { EHOSTUNREACH } from 'constants';

// 数据服务
let dataService1 = new appClient.asyncFactory(platform.IDataService, "remoteCall", "gsqyInfoDataService");

// 数据获取器
/** 获取器:注销企业数变化 */
let fetcher_zxqysbh = new report.dataServiceFetcher();
fetcher_zxqysbh.name = "注销企业数变化";
fetcher_zxqysbh.command = "cmd_fsgs_zxqyqk";
fetcher_zxqysbh.dataService = dataService1;
/** 获取器:注销企业注销类型分布 */
let fetcher_zqqyzxlxfb = new report.dataServiceFetcher();
fetcher_zqqyzxlxfb.name = "注销企业注销类型分布";
fetcher_zqqyzxlxfb.command = "cmd_fsgs_zxlxslfb";
fetcher_zqqyzxlxfb.dataService = dataService1;
/** 获取器: 注销企业企业类型数量分布*/
let fetcher_zxqyqylxfb = new report.dataServiceFetcher();
fetcher_zxqyqylxfb.name = "注销企业企业类型数量分布";
fetcher_zxqyqylxfb.command = "cmd_fsgs_qylxslfb";
fetcher_zxqyqylxfb.dataService = dataService1;
/** 获取器: 注销企业数量各区分布*/
let fetcher_zxqyslgqfb = new report.dataServiceFetcher();
fetcher_zxqyslgqfb.name = "注销企业数量各区分布";
fetcher_zxqyslgqfb.command = "cmd_fsgs_slgqbh";
fetcher_zxqyslgqfb.dataService = dataService1;
/** 获取器:年份查询条件 */
let fetcher_nfcx = new report.dataServiceFetcher();
fetcher_nfcx.name = "年份查询条件";
fetcher_nfcx.command = "cmd_fsgs_zxqynf";
fetcher_nfcx.dataService = dataService1;

// 数据源
/** 数据源:年份查询 */
let dataSource_nfcx = new platform.dataQuerySource();
dataSource_nfcx.name = "data_gssjfx_nfcx";
dataSource_nfcx.fetcher = fetcher_nfcx;
/** 数据源:注销企业企业数变化 */
let dataSource_zxqysbh = new platform.dataQuerySource();
dataSource_zxqysbh.name = "data_gssjfx_zxqysbh";
dataSource_zxqysbh.fetcher = fetcher_zxqysbh;

/** 数据源:注销企业注销类型数量分布*/
let dataSource_zxqyzxlxfb = new platform.dataQuerySource();
dataSource_zxqyzxlxfb.name = "data_gssjfx_zxqyzxlxfb";
dataSource_zxqyzxlxfb.fetcher = fetcher_zqqyzxlxfb;

/** 数据源:注销企业企业类型数量分布 */
let dataSource_zxqyqylxfb = new platform.dataQuerySource();
dataSource_zxqyqylxfb.name = "data_gssjfx_zxqyqylxfb";
dataSource_zxqyqylxfb.fetcher = fetcher_zxqyqylxfb;

/** 数据源:注销企业数量各区变化 */
let dataSource_zxqyslgqbh = new platform.dataQuerySource();
dataSource_zxqyslgqbh.name = "data_gssjfx_zxqyslgqbh";
dataSource_zxqyslgqbh.fetcher = fetcher_zxqyslgqfb;



/** 数据显示器:参数输入 */
let paramReport = new report.parameterControl();


/**
 * 开始年份相同
 */
let ksnfFieldEdit = new report.fieldEditInfo();
ksnfFieldEdit.name = "startnf";
ksnfFieldEdit.defaultData = [];
ksnfFieldEdit.defaultData.push({ 'name': 2017, 'value': 2017 });
ksnfFieldEdit.defaultData.push({ 'name': 2016, 'value': 2016 });
ksnfFieldEdit.defaultData.push({ 'name': 2015, 'value': 2015 });
ksnfFieldEdit.defaultData.push({ 'name': 2014, 'value': 2014 });
let ksnfControl = new platformControls.selectEditControl();
ksnfControl.showField = "name";
ksnfControl.valueField = "value";
ksnfControl.caption = "开始年份";
ksnfControl.defaultValue = true;
ksnfFieldEdit.editControl = ksnfControl;

/**
 * 结束年份相同endnf
 */
let jsnfFieldEdit = new report.fieldEditInfo();
jsnfFieldEdit.name = "endnf";
jsnfFieldEdit.defaultData = ksnfFieldEdit.defaultData;
jsnfFieldEdit.dataSource = dataSource_nfcx;
let jsnfControl = new platformControls.selectEditControl();
jsnfControl.showField = "name";
jsnfControl.valueField = "value";
jsnfControl.caption = "结束年份";
ksnfControl.defaultValue = true;
jsnfFieldEdit.editControl = jsnfControl;

paramReport.name = "report_nfcx_parameters";
paramReport.fields = [ksnfFieldEdit, jsnfFieldEdit];
paramReport.caption = "年份查询";
paramReport.dataSourceNames = ["data_gssjfx_zxqyslgqbh", "data_gssjfx_nfcx",
    "data_gssjfx_zxqyqylxfb", "data_gssjfx_zxqyzxlxfb", "data_gssjfx_zxqysbh"];
paramReport.dataViews = {};
paramReport.queryCount = 100;

/** 数据显示器:注销企业企业数变化 */
let tableReport_zxqysbh = new report.echartsDataDisplayer();
tableReport_zxqysbh.name = "report_gssjfx_zxqysbh";
tableReport_zxqysbh.caption = "注销企业企业数变化";

tableReport_zxqysbh.dataViews = {};
let tableView_zxqysbh = new platform.dataView();
tableView_zxqysbh.dataSourceName = "data_gssjfx_zxqysbh";
tableReport_zxqysbh.dataViews["view_table"] = tableView_zxqysbh;

let axisSerie1 = new echartControls.axisSerie();
//取数据库字段
let field_qysnum = new platform.dataField();
field_qysnum.name = "NUM";
field_qysnum.caption = "企业数";
let field_qynf = new platform.dataField();
field_qynf.name = "NF";
field_qynf.caption = "年份";
//图配置
axisSerie1.xAxis = {
    type: "category",
    axises: [{
        caption: "年份",
        position: "buttom",
        nameLocation: "end",
        color: "white",
    }]
};
axisSerie1.yAxis = {
    type: "value",
    axises: [{
        caption: "企业数量（单位：个）",
        nameLocation: "middle",
        nameGap: 50,
        color: "white",
    }]
};
axisSerie1.categoryFields = [{
    field: field_qynf,
    index: 0
}];
axisSerie1.valueFields = [{
    type: "bar",
    field: field_qysnum,
    xAxisIndex: 0,
    yAxisIndex: 0,
    barMaxWitdh: 50,
    itemStyle: {
        normal: {
            color: "#7CFC00"
        }
    }
}];

tableReport_zxqysbh.echartObject = axisSerie1;


/** 数据显示器: 注销企业注销类型数量分布*/
let tableReport_zxqyzxlxfb = new report.echartsDataDisplayer();
tableReport_zxqyzxlxfb.name = "report_gssjfx_zxqyzxlxfb";
tableReport_zxqyzxlxfb.caption = "注销企业注销类型数量分布";

tableReport_zxqyzxlxfb.dataViews = {};
let tableView_zxqyzxlxfb = new platform.dataView();
tableView_zxqyzxlxfb.dataSourceName = "data_gssjfx_zxqyzxlxfb";
tableReport_zxqyzxlxfb.dataViews["view_table"] = tableView_zxqyzxlxfb;
//tableReport_zxqyzxlxfb.style("height", 500);
let axisSerie2 = new echartControls.axisSerie();
//取数据库字段
let field_zxnum = new platform.dataField();
field_zxnum.name = "NUM";
field_zxnum.caption = "企业注销数";
let field_zxlx = new platform.dataField();
field_zxlx.name = "ZXLX";
field_zxlx.caption = "注销类型";
//图配置
axisSerie2.xAxis = {
    type: "category",
    axises: [{
        caption: "注销类型",
        position: "buttom",
        nameLocation: "end",
        color: "white",
    }]
};
axisSerie2.yAxis = {
    type: "value",
    axises: [{
        caption: "企业数量（单位：个）",
        nameLocation: "middle",
        nameGap: 50,
        color: "white",
    }]
};
axisSerie2.categoryFields = [{
    field: field_zxlx,
    index: 0
}];
axisSerie2.valueFields = [{
    type: "bar",
    field: field_zxnum,
    xAxisIndex: 0,
    yAxisIndex: 0
}];
axisSerie2.currentGrid = {
    y2: 120,
    x2: 100
};
axisSerie2.italic = true;
tableReport_zxqyzxlxfb.echartObject = axisSerie2;

/** 数据显示器: 注销企业企业类型数量分布*/
let tableReport_zxqyqylxfb = new report.echartsDataDisplayer();
tableReport_zxqyqylxfb.name = "report_gssjfx_zxqyqylxfb";
tableReport_zxqyqylxfb.caption = "注销企业企业类型数量分布";

tableReport_zxqyqylxfb.dataViews = {};
let tableView_zxqyqylxfb = new platform.dataView();
tableView_zxqyqylxfb.dataSourceName = "data_gssjfx_zxqyqylxfb";
tableReport_zxqyqylxfb.dataViews["view_table"] = tableView_zxqyqylxfb;

//柱状图
let axisSerie = new echartControls.axisSerie();
//取数据库字段
let field_num = new platform.dataField();
field_num.name = "NUM";
field_num.caption = "数量";
let field_qylx = new platform.dataField();
field_qylx.name = "QYLX";
field_qylx.caption = "企业类型";
//图配置
axisSerie.xAxis = {
    type: "category",
    axises: [{
        caption: "企业类型",
        position: "buttom",
        nameLocation: "end",
        color: "white",
    }]
};
axisSerie.yAxis = {
    type: "value",
    axises: [{
        caption: "企业数量（单位：个）",
        nameLocation: "middle",
        nameGap: 50,
        color: "white",

    }]
};
axisSerie.categoryFields = [{
    field: field_qylx,
    index: 0
}];
axisSerie.valueFields = [{
    type: "bar",
    field: field_num,
    xAxisIndex: 0,
    yAxisIndex: 0
}];
axisSerie.currentGrid = {
    y2: 120,
    x2: 100
};
axisSerie.italic = true;
tableReport_zxqyqylxfb.echartObject = axisSerie;

//  数据显示器: 注销企业数量各区变化


let tableReport_zxqyslgqbh = new report.echartsDataDisplayer();
tableReport_zxqyslgqbh.name = "report_gssjfx_zxqyslgqbh";
tableReport_zxqyslgqbh.caption = "注销企业数量各区变化";

tableReport_zxqyslgqbh.dataViews = {};
let tableView_zxqyslgqbh = new platform.dataView();
tableView_zxqyslgqbh.dataSourceName = "data_gssjfx_zxqyslgqbh";
tableReport_zxqyslgqbh.dataViews["view_table"] = tableView_zxqyslgqbh;

let axisSerie3 = new echartControls.axisSerie();
//取数据库字段
let field_gqnf = new platform.dataField();
field_gqnf.name = "NF";
field_gqnf.caption = "年份";
let field_cc = new platform.dataField();
field_cc.name = "CC";
field_cc.caption = "禅城";
let field_nh = new platform.dataField();
field_nh.name = "NH";
field_nh.caption = "南海";
let field_sd = new platform.dataField();
field_sd.name = "SD";
field_sd.caption = "顺德";
let field_gm = new platform.dataField();
field_gm.name = "GM";
field_gm.caption = "高明";
let field_ss = new platform.dataField();
field_ss.name = "SS";
field_ss.caption = "三水";
let field_qt = new platform.dataField();
field_qt.name = "QT";
field_qt.caption = "其他";
//图配置
axisSerie3.xAxis = {
    type: "category",
    axises: [{
        caption: "年份",
        position: "buttom",
        nameLocation: "end",
        color: "white",
    }]
};
axisSerie3.yAxis = {
    type: "value",
    axises: [{
        caption: "企业数量（单位：个）",
        nameLocation: "middle",
        nameGap: 50,
        color: "white",
    }]
};
axisSerie3.categoryFields = [{
    field: field_gqnf,
    index: 0
}];
axisSerie3.valueFields = [{
    type: "line",
    field: field_cc,
    xAxisIndex: 0,
    yAxisIndex: 0
},
{
    type: "line",
    field: field_nh,
    xAxisIndex: 0,
    yAxisIndex: 0
},
{
    type: "line",
    field: field_sd,
    xAxisIndex: 0,
    yAxisIndex: 0
},
{
    type: "line",
    field: field_gm,
    xAxisIndex: 0,
    yAxisIndex: 0
},
{
    type: "line",
    field: field_ss,
    xAxisIndex: 0,
    yAxisIndex: 0
},
{
    type: "line",
    field: field_qt,
    xAxisIndex: 0,
    yAxisIndex: 0
}
];
tableReport_zxqyslgqbh.echartObject = axisSerie3;
//


/**
 * 佛山国税智能报表
 * @description 工商数据分析
 */
export let defaultObject = new report.smartReport();
defaultObject.caption = "工商数据分析";
defaultObject.dataSources = {};
defaultObject.dataSources[dataSource_nfcx.name] = dataSource_nfcx;
defaultObject.dataSources[dataSource_zxqysbh.name] = dataSource_zxqysbh;
defaultObject.dataSources[dataSource_zxqyzxlxfb.name] = dataSource_zxqyzxlxfb;
defaultObject.dataSources[dataSource_zxqyqylxfb.name] = dataSource_zxqyqylxfb;
defaultObject.dataSources[dataSource_zxqyslgqbh.name] = dataSource_zxqyslgqbh;
defaultObject.layoutPanel = new platformControls.layoutPanel("project/dataAnalysis/gsDataAnalysis/config/client/layout/layout.html");
defaultObject.modules = {};
defaultObject.modules[paramReport.name] = paramReport;
defaultObject.modules[tableReport_zxqysbh.name] = tableReport_zxqysbh;
defaultObject.modules[tableReport_zxqyzxlxfb.name] = tableReport_zxqyzxlxfb;
defaultObject.modules[tableReport_zxqyqylxfb.name] = tableReport_zxqyqylxfb;
defaultObject.modules[tableReport_zxqyslgqbh.name] = tableReport_zxqyslgqbh;
defaultObject.autoQuery = false;
